package com.lightsh.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Utility {
	
	/**
	 * 记录widget相关的信息
	 */
	public static final String PREFERENCES_WIDGET_INFO = "PreferencesWidgetInfo";
	public static final String SETTING_REGET_DATA_INTERVAL = "SettingRegetDataInterval";
	
	
	/**
	 * widget默认的刷新间隔(只刷新数据而非刷新网络内容)
	 */
	public static final long WIDGET_REFRESH_INIT_INTERVAL = 10000;
	
	/**
	 * widget默认的更新网络数据的间隔
	 */
	public static final long WIDGET_REGET_DATA_INTERVAL = 200000;
	
	
	public static boolean isNetworkAvailable( Context context){
		ConnectivityManager connectivity = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		if( connectivity == null ){
			return false;
		}else{
			
			NetworkInfo info = connectivity.getActiveNetworkInfo();
			if( info != null ){
				if (info.getState() == NetworkInfo.State.CONNECTED) {
					return true;
				}
			}
		}
        return false;
    }
}
